package org.jeecg.modules.gqHealth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.gqHealth.entity.GqRealnameInfo;
import org.jeecg.modules.gqHealth.mapper.GqRealnameInfoMapper;
import org.jeecg.modules.gqHealth.service.IGqRealnameInfoService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.List;

/**
 * @Description: 用户实名信息表
 * @Author: jeecg-boot
 * @Date:   2024-05-08
 * @Version: V1.0
 */
@Service
public class GqRealnameInfoServiceImpl extends ServiceImpl<GqRealnameInfoMapper, GqRealnameInfo> implements IGqRealnameInfoService {

    @Override
    public Result<?> realNameConfirm() {
        HashMap<String, Object> map = new HashMap<>();
//        未审核人数
        int unchecked = getStatusUsers(0);
//        通过人数
        int approve = getStatusUsers(1);
//        未通过人数
        int notPass = getStatusUsers(2);
        map.put("unchecked",unchecked);
        map.put("approve",approve);
        map.put("notPass",notPass);
        return Result.ok(map);
    }

    /***
     * 查询个状态实名人数
     * @param status
     * @return
     */
    private int getStatusUsers(int status) {
        LambdaQueryWrapper<GqRealnameInfo> gqRealnameInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
        gqRealnameInfoLambdaQueryWrapper.eq(GqRealnameInfo::getStatus,status);
        List<GqRealnameInfo> list = this.list(gqRealnameInfoLambdaQueryWrapper);
        if(null == list || list.isEmpty()){
            return 0;
        }
        return list.size();
    }
}
